package com.liuliu.blogelasticsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

@Configuration
public class ElasticConfig {

    @Bean
    public RestHighLevelClient restHighLevelClient(){
        HttpHost localhost = new HttpHost("localhost", 9200);
        List<HttpHost> httpHosts = Arrays.asList(localhost);
        RestClientBuilder builder = RestClient.builder(localhost);
        builder.setRequestConfigCallback(builder1 -> builder1);
        builder.setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder);
        return new RestHighLevelClient(builder);
    }
}
